var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
function consistSting(allowed, world) {
    var sum = 0;
    world.forEach(function (item) {
        var newArr = item.split('');
        if (newArr.every(function (item) { return allowed.indexOf(item) !== -1; })) {
            sum++;
        }
    });
    return sum;
}
console.log(consistSting('ab', ['ab', 'db', 'aab', 'ccd']));
function searurl(url) {
    var paramstr = url.split('?')[1];
    var parr = paramstr.split('&');
    var obj = {};
    parr.forEach(function (item) {
        var _a;
        var key = item.split('=')[0];
        var value = item.split('=')[1];
        var newobj = (_a = {},
            _a[key] = value,
            _a);
        obj = __assign(__assign({}, obj), newobj);
    });
    return obj;
}
console.log(searurl('http://www.info.com?name=哈哈&age=12&address=考试&sex=男'));
function func(price) {
    var profit = 0;
    for (var i = 1; i < price.length; i++) {
        var tmp = price[i] - price[i - 1];
        if (tmp > 0)
            profit += tmp;
    }
    return profit;
}
console.log(func([7, 5, 8, 1, 2]));
function single(nums) {
    var num = -1;
    for (var i = 0; i < nums.length; i++) {
        if (nums.indexOf(nums[i]) == nums.lastIndexOf(nums[i])) {
            num = nums[i];
        }
    }
    return num;
}
console.log(single([1, 2, 3, 4, 5, 3, 2]));
function flat(arr, k) {
    if (k === void 0) { k = 1; }
    var newArr = [];
    arr.forEach(function (item) {
        if (Array.isArray(item) && k > 1) {
            newArr = newArr.concat(flat(item, k - 1));
        }
        else {
            newArr = newArr.concat(item);
        }
    });
    return newArr;
}
console.log(flat([1, [2, 3, [4, 5]]], 1));
